package com.wmh.baseservice.skd.mapper;

import com.wmh.baseservice.skd.pojo.SkdCollect;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author CH
* @description 针对表【skd_collect】的数据库操作Mapper
* @createDate 2024-01-23 11:09:15
* @Entity com.wmh.baseservice.skd.pojo.SkdCollect
*/
public interface SkdCollectMapper extends BaseMapper<SkdCollect> {
    /**
     * 根据用户id获取团购活动id列表
     * @param usId 用户id
     * @return 返回团购活动id列表
     */
    @Select("SELECT id, group_buying_activity_id, create_time FROM skd_collect WHERE user_id = #{usId} AND deleted = 0")
    List<SkdCollect> getByUserId(Long usId);

    @Select("SELECT c.id, c.group_buying_activity_id, c.create_time " +
            "FROM skd_collect c " +
            "JOIN skd_group_buying_activities g ON c.group_buying_activity_id = g.id " +
            "WHERE g.title LIKE CONCAT('%', #{searchName}, '%') AND c.user_id = #{userId} AND c.deleted = 0")
    List<SkdCollect> searchCollect(String searchName, Long userId);
}




